package algorithms;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.sun.media.jai.codec.TIFFEncodeParam;
import com.sun.media.jai.codecimpl.TIFFImageEncoder;

public class ModifiedHuffman implements LosslessCompressionAlgorithm {

	private String _extension = "mhf";

	@Override
	public void encode(File fileIn, File fileOut) throws IOException {

		System.setProperty("com.sun.media.jai.disableMediaLib", "true");
		FileOutputStream out = new FileOutputStream(fileOut);
		TIFFEncodeParam params = new TIFFEncodeParam();
		params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP3_1D);
		TIFFImageEncoder enc = new TIFFImageEncoder(out, params);
		enc.encode(ImageIO.read(fileIn));
		out.close();
	}

	@Override
	public void decode(File fileIn, File fileOut) throws IOException {

	}

	@Override
	public String getFileExtension() {
		return _extension;
	}

	@Override
	public void setFileExtension(String name) {
		_extension = name;
	}

}
